#include "transformable.h"
#include <osg\Vec2>
#include <osg\Group>
#include "commonshape.h"
#include <osg\TextureCubeMap>
#include <osg\Uniform>

namespace VrDataCore
{
	class CoreBase::ActorBase;

	class PoorerWater: public CoreBase::Transformable
	{
	public:
		PoorerWater(CoreBase::ActorBase* owneractor,const QString& name = "PoorerWater");
		void setSize(const osg::Vec2& size);
		virtual bool addChild(CoreBase::Drawable* child);
		virtual void addedToScene(CoreBase::Scene* scene);
		void setEnvironmentParameter(osg::TextureCubeMap* texture,const osg::Vec4& lightcolor,const osg::Vec4& fogcolors,
			const osg::Vec4& waterfogcolors,const osg::Vec4& underwaterdiffuse,const osg::Vec3& underwaterattenuations
			,const osg::Vec3& sunpositions,const osg::Vec4& sundiffuse);
	protected:
		void build();
		~PoorerWater();
		QString												_rotationZ;
		osg::Vec2											_size;
		osg::ref_ptr<osg::Group>							_root;
		bool												_inScene;
		osg::ref_ptr<CoreBase::PlaneShape>					_planeShape;
		osg::ref_ptr<osg::StateSet>							_ss;
		osg::TextureCubeMap*								_skyTextureCubeMap;
	};

	class UpdateShader : public osg::Uniform::Callback
	{
	public:
		UpdateShader() : time(0.0), dir(true) {}
		virtual void operator() ( osg::Uniform* uniform, osg::NodeVisitor* nv )
		{
			time += 0.08;
			uniform->set( time );
		}
		bool dir;
		float time;
	};
}